﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace Entity
{
     public class ApiDBContext:DbContext
    {
        private readonly string? _ConnectionString;

        public ApiDBContext(DbContextOptions<ApiDBContext> opts) : base(opts)
        {

        }
        DbSet<EntityUser> EntityUser { get; set; }
        ///protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        ///{
        ///optionsBuilder.UseMySql(_ConnectionString, new MySqlServerVersion(new Version(9,2,0)) );
        ///}
        ///protected override void OnModelCreating(ModelBuilder modelBuilder)
        ///{
        ///modelBuilder.UseCollation("uft8mb4").HasCharSet("utf8mb4_german2_ci");
        ///}
        ///

        public ApiDBContext CreateDBContext(string[] args)
        {
            var optionBuilder = new DbContextOptionsBuilder<ApiDBContext>();
            optionBuilder.UseMySql(
                "Server=localhost;User=root;Password=123456;database=AIYDB;port=3306;",
                new MySqlServerVersion(new Version(8, 0, 41))
                );
            return new ApiDBContext(optionBuilder.Options);
        }

    }
}